/* Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "zobjects_gtk.h"

/*
static void OnVideoSizeChanged( GObject *object , GAsyncResult *result , gpointer user_data )
{
	GtkMediaStream		*media_stream = NULL ;
	int			width_request , height_request ;
	GtkWidget		*boxlayout = NULL ;

	media_stream = gtk_video_get_media_stream( GTK_VIDEO(object) ) ;
	if( ! gtk_media_stream_is_prepared(media_stream) )
		return;
	
	gtk_widget_get_size_request( GTK_WIDGET(object) , & width_request , & height_request );

	boxlayout = gtk_widget_get_parent( GTK_WIDGET(object) ) ;
	gtk_widget_set_size_request( boxlayout , width_request , height_request );

	return;
}
*/

ZlangInvokeFunction ZlangInvokeFunction_guivideo_Create_guiwindow;
int ZlangInvokeFunction_guivideo_Create_guiwindow( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangObject				*in1 = GetInputParameterInLocalObjectStack(rt,1) ;
	struct ZlangObject				*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;
	struct ZlangDirectProperty_guivideo		*guivideo_direct_prop = GetObjectDirectProperty(out1) ;
	struct ZlangDirectProperty_guiwidget_common	*guivideo_common = & (guivideo_direct_prop->common) ;

	EVAL_GTK_WIDGET_NEW_IN_CREATE( guivideo_common->gtk_widget , gtk_video_new() )
	SET_CONTROL_DEFAULT_STYLE( in1 , guivideo_common->gtk_widget )

	TRANSFER_INPUT_OBJECT_TO_NEW_OBJECT( guivideo_common->guiwindow_obj , in1 )
	
	return 0;
}

ZlangInvokeFunction ZlangInvokeFunction_guivideo_Create_guiwindow_string;
int ZlangInvokeFunction_guivideo_Create_guiwindow_string( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangObject				*in1 = GetInputParameterInLocalObjectStack(rt,1) ;
	struct ZlangObject				*in2 = GetInputParameterInLocalObjectStack(rt,2) ;
	struct ZlangObject				*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;
	char						*video_filename = NULL ;
	struct ZlangDirectProperty_guivideo		*guivideo_direct_prop = GetObjectDirectProperty(out1) ;
	struct ZlangDirectProperty_guiwidget_common	*guivideo_common = & (guivideo_direct_prop->common) ;

	CallRuntimeFunction_string_GetStringValue( rt , in2 , & video_filename , NULL );

	EVAL_GTK_WIDGET_NEW_IN_CREATE( guivideo_common->gtk_widget , gtk_video_new_for_filename(video_filename) )
	SET_CONTROL_DEFAULT_STYLE( in1 , guivideo_common->gtk_widget )

	TRANSFER_INPUT_OBJECT_TO_NEW_OBJECT( guivideo_common->guiwindow_obj , in1 )

	return 0;
}

ZlangInvokeFunction ZlangInvokeFunction_guivideo_SetAutoPlay_bool;
int ZlangInvokeFunction_guivideo_SetAutoPlay_bool( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guivideo		*guivideo_direct_prop = GetObjectDirectProperty(obj) ;
	struct ZlangDirectProperty_guiwidget_common	*guivideo_common = & (guivideo_direct_prop->common) ;
	struct ZlangObject				*in1 = GetInputParameterInLocalObjectStack(rt,1) ;
	struct ZlangObject				*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;
	unsigned char					is_auto_play ;

	CallRuntimeFunction_bool_GetBoolValue( rt , in1 , & is_auto_play );

	gtk_video_set_autoplay( GTK_VIDEO(guivideo_common->gtk_widget) , is_auto_play );

	TRANSFER_MASTER_OBJECT_TO_OUTPUT_OBJECT

	return 0;
}

ZlangInvokeFunction ZlangInvokeFunction_guivideo_SetLoopPlay_bool;
int ZlangInvokeFunction_guivideo_SetLoopPlay_bool( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guivideo		*guivideo_direct_prop = GetObjectDirectProperty(obj) ;
	struct ZlangDirectProperty_guiwidget_common	*guivideo_common = & (guivideo_direct_prop->common) ;
	struct ZlangObject				*in1 = GetInputParameterInLocalObjectStack(rt,1) ;
	struct ZlangObject				*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;
	unsigned char					is_loop_play ;

	CallRuntimeFunction_bool_GetBoolValue( rt , in1 , & is_loop_play );

	gtk_video_set_loop( GTK_VIDEO(guivideo_common->gtk_widget) , is_loop_play );

	TRANSFER_MASTER_OBJECT_TO_OUTPUT_OBJECT

	return 0;
}

ZlangInvokeFunction ZlangInvokeFunction_guivideo_SetMuted_bool;
int ZlangInvokeFunction_guivideo_SetMuted_bool( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guivideo		*guivideo_direct_prop = GetObjectDirectProperty(obj) ;
	struct ZlangDirectProperty_guiwidget_common	*guivideo_common = & (guivideo_direct_prop->common) ;
	struct ZlangObject				*in1 = GetInputParameterInLocalObjectStack(rt,1) ;
	struct ZlangObject				*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;
	unsigned char					is_muted ;
	GtkMediaStream					*media_stream = NULL ;

	CallRuntimeFunction_bool_GetBoolValue( rt , in1 , & is_muted );

	media_stream = gtk_video_get_media_stream( GTK_VIDEO(guivideo_common->gtk_widget) ) ;
	if( media_stream && gtk_media_stream_is_prepared(media_stream) )
	{
		gtk_media_stream_set_muted( media_stream , is_muted );
	}

	TRANSFER_MASTER_OBJECT_TO_OUTPUT_OBJECT

	return 0;
}

ZlangInvokeFunction ZlangInvokeFunction_guivideo_SetVolume_double;
int ZlangInvokeFunction_guivideo_SetVolume_double( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guivideo		*guivideo_direct_prop = GetObjectDirectProperty(obj) ;
	struct ZlangDirectProperty_guiwidget_common	*guivideo_common = & (guivideo_direct_prop->common) ;
	struct ZlangObject				*in1 = GetInputParameterInLocalObjectStack(rt,1) ;
	struct ZlangObject				*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;
	double						volume ;
	GtkMediaStream					*media_stream = NULL ;

	CallRuntimeFunction_double_GetDoubleValue( rt , in1 , & volume );

	media_stream = gtk_video_get_media_stream( GTK_VIDEO(guivideo_common->gtk_widget) ) ;
	if( media_stream && gtk_media_stream_is_prepared(media_stream) )
	{
		if( volume > 1.00 )
			volume = 1.00 ;
		else if( volume < 0.00 )
			volume = 0.00 ;
		gtk_media_stream_set_volume( media_stream , volume );
	}

	TRANSFER_MASTER_OBJECT_TO_OUTPUT_OBJECT

	return 0;
}

ZlangInvokeFunction ZlangInvokeFunction_guivideo_LoadVideoFile_string;
int ZlangInvokeFunction_guivideo_LoadVideoFile_string( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guivideo		*guivideo_direct_prop = GetObjectDirectProperty(obj) ;
	struct ZlangDirectProperty_guiwidget_common	*guivideo_common = & (guivideo_direct_prop->common) ;
	struct ZlangObject				*in1 = GetInputParameterInLocalObjectStack(rt,1) ;
	struct ZlangObject				*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;
	char						*video_pathfilename = NULL ;

	CallRuntimeFunction_string_GetStringValue( rt , in1 , & video_pathfilename , NULL );

	gtk_video_set_autoplay( GTK_VIDEO(guivideo_common->gtk_widget) , TRUE );
	GFile *file = g_file_new_for_path( video_pathfilename ) ;
	gtk_video_set_file( GTK_VIDEO(guivideo_common->gtk_widget) , file );
	g_object_unref( file );

	TRANSFER_MASTER_OBJECT_TO_OUTPUT_OBJECT

	return 0;
}

ZLANG_INVOKE_FUNCTION_guiwidget_all_common_functions( video )

ZLANG_INVOKE_FUNCTION_guictl_all_common_functions( video )

ZlangInvokeFunction ZlangInvokeFunction_guivideo_GetVideoWidth;
int ZlangInvokeFunction_guivideo_GetVideoWidth( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guivideo		*guivideo_direct_prop = GetObjectDirectProperty(obj) ;
	struct ZlangDirectProperty_guiwidget_common	*guivideo_common = & (guivideo_direct_prop->common) ;
	struct ZlangObject				*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;
	GtkMediaStream					*media_stream = NULL ;
	int32_t						width ;

	media_stream = gtk_video_get_media_stream( GTK_VIDEO(guivideo_common->gtk_widget) ) ;
	if( media_stream )
	{
		width = gdk_paintable_get_intrinsic_width( GDK_PAINTABLE(media_stream) ) ;
		CallRuntimeFunction_int_SetIntValue( rt , out1 , width );
	}
	else
	{
		CallRuntimeFunction_int_SetIntValue( rt , out1 , -1 );
	}

	return 0;
}

ZlangInvokeFunction ZlangInvokeFunction_guivideo_GetVideoHeight;
int ZlangInvokeFunction_guivideo_GetVideoHeight( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guivideo		*guivideo_direct_prop = GetObjectDirectProperty(obj) ;
	struct ZlangDirectProperty_guiwidget_common	*guivideo_common = & (guivideo_direct_prop->common) ;
	struct ZlangObject				*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;
	GtkMediaStream					*media_stream = NULL ;
	int32_t						height ;

	media_stream = gtk_video_get_media_stream( GTK_VIDEO(guivideo_common->gtk_widget) ) ;
	if( media_stream )
	{
		height = gdk_paintable_get_intrinsic_height( GDK_PAINTABLE(media_stream) ) ;
		CallRuntimeFunction_int_SetIntValue( rt , out1 , height );
	}
	else
	{
		CallRuntimeFunction_int_SetIntValue( rt , out1 , -1 );
	}

	return 0;
}

ZlangInvokeFunction ZlangInvokeFunction_guivideo_GetAutoPlay;
int ZlangInvokeFunction_guivideo_GetAutoPlay( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guivideo		*guivideo_direct_prop = GetObjectDirectProperty(obj) ;
	struct ZlangDirectProperty_guiwidget_common	*guivideo_common = & (guivideo_direct_prop->common) ;
	struct ZlangObject				*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;
	unsigned char					is_auto_play ;

	is_auto_play = gtk_video_get_autoplay( GTK_VIDEO(guivideo_common->gtk_widget) ) ;

	CallRuntimeFunction_bool_SetBoolValue( rt , out1 , is_auto_play );

	return 0;
}

ZlangInvokeFunction ZlangInvokeFunction_guivideo_GetLoopPlay;
int ZlangInvokeFunction_guivideo_GetLoopPlay( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guivideo		*guivideo_direct_prop = GetObjectDirectProperty(obj) ;
	struct ZlangDirectProperty_guiwidget_common	*guivideo_common = & (guivideo_direct_prop->common) ;
	struct ZlangObject				*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;
	unsigned char					is_loop_play ;

	is_loop_play = gtk_video_get_loop( GTK_VIDEO(guivideo_common->gtk_widget) ) ;

	CallRuntimeFunction_bool_SetBoolValue( rt , out1 , is_loop_play );

	return 0;
}

ZlangInvokeFunction ZlangInvokeFunction_guivideo_GetMuted;
int ZlangInvokeFunction_guivideo_GetMuted( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guivideo		*guivideo_direct_prop = GetObjectDirectProperty(obj) ;
	struct ZlangDirectProperty_guiwidget_common	*guivideo_common = & (guivideo_direct_prop->common) ;
	struct ZlangObject				*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;
	GtkMediaStream					*media_stream = NULL ;
	unsigned char					is_muted ;

	media_stream = gtk_video_get_media_stream( GTK_VIDEO(guivideo_common->gtk_widget) ) ;
	if( media_stream )
	{
		is_muted = gtk_media_stream_get_muted( media_stream ) ;
	}
	else
	{
		is_muted = FALSE ;
	}

	CallRuntimeFunction_bool_SetBoolValue( rt , out1 , is_muted );

	return 0;
}

ZlangInvokeFunction ZlangInvokeFunction_guivideo_GetVolume;
int ZlangInvokeFunction_guivideo_GetVolume( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guivideo		*guivideo_direct_prop = GetObjectDirectProperty(obj) ;
	struct ZlangDirectProperty_guiwidget_common	*guivideo_common = & (guivideo_direct_prop->common) ;
	struct ZlangObject				*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;
	GtkMediaStream					*media_stream = NULL ;
	double						volume ;

	media_stream = gtk_video_get_media_stream( GTK_VIDEO(guivideo_common->gtk_widget) ) ;
	if( media_stream )
	{
		volume = gtk_media_stream_get_volume( media_stream ) ;
	}
	else
	{
		volume = 0.00 ;
	}

	CallRuntimeFunction_double_SetDoubleValue( rt , out1 , volume );

	return 0;
}

ZlangInvokeFunction ZlangInvokeFunction_guivideo_Play;
int ZlangInvokeFunction_guivideo_Play( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guivideo		*guivideo_direct_prop = GetObjectDirectProperty(obj) ;
	struct ZlangDirectProperty_guiwidget_common	*guivideo_common = & (guivideo_direct_prop->common) ;
	struct ZlangObject				*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;
	GtkMediaStream					*media_stream = NULL ;

	media_stream = gtk_video_get_media_stream( GTK_VIDEO(guivideo_common->gtk_widget) ) ;
	if( media_stream && gtk_media_stream_is_prepared( media_stream ) )
	{
		gtk_media_stream_play( media_stream );
		CallRuntimeFunction_bool_SetBoolValue( rt , out1 , TRUE );
	}
	else
	{
		CallRuntimeFunction_bool_SetBoolValue( rt , out1 , FALSE );
	}

	return 0;
}

ZlangInvokeFunction ZlangInvokeFunction_guivideo_Stop;
int ZlangInvokeFunction_guivideo_Stop( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guivideo		*guivideo_direct_prop = GetObjectDirectProperty(obj) ;
	struct ZlangDirectProperty_guiwidget_common	*guivideo_common = & (guivideo_direct_prop->common) ;
	struct ZlangObject				*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;
	GtkMediaStream					*media_stream = NULL ;

	media_stream = gtk_video_get_media_stream( GTK_VIDEO(guivideo_common->gtk_widget) ) ;
	if( media_stream && gtk_media_stream_is_prepared( media_stream ) )
	{
		gtk_media_stream_stream_ended( media_stream );
		gtk_media_stream_seek( media_stream , 0 );
		CallRuntimeFunction_bool_SetBoolValue( rt , out1 , TRUE );
	}
	else
	{
		CallRuntimeFunction_bool_SetBoolValue( rt , out1 , FALSE );
	}

	return 0;
}

ZlangInvokeFunction ZlangInvokeFunction_guivideo_Pause;
int ZlangInvokeFunction_guivideo_Pause( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guivideo		*guivideo_direct_prop = GetObjectDirectProperty(obj) ;
	struct ZlangDirectProperty_guiwidget_common	*guivideo_common = & (guivideo_direct_prop->common) ;
	struct ZlangObject				*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;
	GtkMediaStream					*media_stream = NULL ;

	media_stream = gtk_video_get_media_stream( GTK_VIDEO(guivideo_common->gtk_widget) ) ;
	if( media_stream && gtk_media_stream_is_prepared( media_stream ) )
	{
		gtk_media_stream_pause( media_stream );
		CallRuntimeFunction_bool_SetBoolValue( rt , out1 , TRUE );
	}
	else
	{
		CallRuntimeFunction_bool_SetBoolValue( rt , out1 , FALSE );
	}

	return 0;
}

ZlangInvokeFunction ZlangInvokeFunction_guivideo_IsPrepared;
int ZlangInvokeFunction_guivideo_IsPrepared( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guivideo		*guivideo_direct_prop = GetObjectDirectProperty(obj) ;
	struct ZlangDirectProperty_guiwidget_common	*guivideo_common = & (guivideo_direct_prop->common) ;
	struct ZlangObject				*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;
	GtkMediaStream					*media_stream = NULL ;

	media_stream = gtk_video_get_media_stream( GTK_VIDEO(guivideo_common->gtk_widget) ) ;
	if( media_stream && gtk_media_stream_is_prepared( media_stream ) )
	{
		CallRuntimeFunction_bool_SetBoolValue( rt , out1 , TRUE );
	}
	else
	{
		CallRuntimeFunction_bool_SetBoolValue( rt , out1 , FALSE );
	}

	return 0;
}

ZlangInvokeFunction ZlangInvokeFunction_guivideo_GetDuration;
int ZlangInvokeFunction_guivideo_GetDuration( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guivideo		*guivideo_direct_prop = GetObjectDirectProperty(obj) ;
	struct ZlangDirectProperty_guiwidget_common	*guivideo_common = & (guivideo_direct_prop->common) ;
	struct ZlangObject				*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;
	GtkMediaStream					*media_stream = NULL ;
	int64_t						duration ;

	media_stream = gtk_video_get_media_stream( GTK_VIDEO(guivideo_common->gtk_widget) ) ;
	if( media_stream && gtk_media_stream_is_prepared( media_stream ) )
	{
		duration = gtk_media_stream_get_duration( media_stream ) ;
		CallRuntimeFunction_long_SetLongValue( rt , out1 , duration );
	}
	else
	{
		CallRuntimeFunction_long_SetLongValue( rt , out1 , -1 );
	}

	return 0;
}

ZlangInvokeFunction ZlangInvokeFunction_guivideo_GetTimestamp;
int ZlangInvokeFunction_guivideo_GetTimestamp( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guivideo		*guivideo_direct_prop = GetObjectDirectProperty(obj) ;
	struct ZlangDirectProperty_guiwidget_common	*guivideo_common = & (guivideo_direct_prop->common) ;
	struct ZlangObject				*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;
	GtkMediaStream					*media_stream = NULL ;
	int64_t						timestamp ;

	media_stream = gtk_video_get_media_stream( GTK_VIDEO(guivideo_common->gtk_widget) ) ;
	if( media_stream && gtk_media_stream_is_prepared( media_stream ) )
	{
		timestamp = gtk_media_stream_get_timestamp( media_stream ) ;
		CallRuntimeFunction_long_SetLongValue( rt , out1 , timestamp );
	}
	else
	{
		CallRuntimeFunction_long_SetLongValue( rt , out1 , -1 );
	}

	return 0;
}

ZlangInvokeFunction ZlangInvokeFunction_guivideo_Seek_long;
int ZlangInvokeFunction_guivideo_Seek_long( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guivideo		*guivideo_direct_prop = GetObjectDirectProperty(obj) ;
	struct ZlangDirectProperty_guiwidget_common	*guivideo_common = & (guivideo_direct_prop->common) ;
	struct ZlangObject				*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;
	GtkMediaStream					*media_stream = NULL ;
	int64_t						seek_timestamp ;

	CallRuntimeFunction_long_GetLongValue( rt , out1 , & seek_timestamp );

	media_stream = gtk_video_get_media_stream( GTK_VIDEO(guivideo_common->gtk_widget) ) ;
	if( media_stream && gtk_media_stream_is_prepared( media_stream ) )
	{
		gtk_media_stream_seek( media_stream , seek_timestamp );
		CallRuntimeFunction_bool_SetBoolValue( rt , out1 , TRUE );
	}
	else
	{
		CallRuntimeFunction_bool_SetBoolValue( rt , out1 , FALSE );
	}

	return 0;
}

ZlangInvokeFunction ZlangInvokeFunction_guivideo_SeekOffset_long;
int ZlangInvokeFunction_guivideo_SeekOffset_long( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guivideo		*guivideo_direct_prop = GetObjectDirectProperty(obj) ;
	struct ZlangDirectProperty_guiwidget_common	*guivideo_common = & (guivideo_direct_prop->common) ;
	struct ZlangObject				*in1 = GetInputParameterInLocalObjectStack(rt,1) ;
	struct ZlangObject				*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;
	GtkMediaStream					*media_stream = NULL ;
	int64_t						seekoffset_timestamp ;
	int64_t						seek_timestamp ;

	CallRuntimeFunction_long_GetLongValue( rt , in1 , & seekoffset_timestamp );

	media_stream = gtk_video_get_media_stream( GTK_VIDEO(guivideo_common->gtk_widget) ) ;
	if( media_stream && gtk_media_stream_is_prepared( media_stream ) )
	{
		seek_timestamp = gtk_media_stream_get_timestamp( media_stream ) ;
		seek_timestamp += seekoffset_timestamp ;
		gtk_media_stream_seek( media_stream , seek_timestamp );
		CallRuntimeFunction_bool_SetBoolValue( rt , out1 , TRUE );
	}
	else
	{
		CallRuntimeFunction_bool_SetBoolValue( rt , out1 , FALSE );
	}

	return 0;
}

ZlangCreateDirectPropertyFunction ZlangCreateDirectProperty_guivideo;
void *ZlangCreateDirectProperty_guivideo( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guivideo		*guivideo_prop = NULL ;
	struct ZlangDirectProperty_guiwidget_common	*guivideo_common = NULL ;
	
	guivideo_prop = (struct ZlangDirectProperty_guivideo *)ZLMALLOC( sizeof(struct ZlangDirectProperty_guivideo) ) ;
	if( guivideo_prop == NULL )
	{
		SET_RUNTIME_ERROR( rt , RUNTIME_ERROR , ZLANG_ERROR_ALLOC , "alloc memory for entity" )
		return NULL;
	}
	memset( guivideo_prop , 0x00 , sizeof(struct ZlangDirectProperty_guivideo) );

	guivideo_common = (struct ZlangDirectProperty_guiwidget_common *)guivideo_prop ;
	guivideo_common->gtk_widget_type_id = GTK_TYPE_VIDEO ;

	INIT_ZLANGDIRECTPROPERTY_guiwidget_common(guivideo)
	
	return guivideo_prop;
}

ZlangDestroyDirectPropertyFunction ZlangDestroyDirectProperty_guivideo;
void ZlangDestroyDirectProperty_guivideo( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guivideo	*guivideo_direct_prop = GetObjectDirectProperty(obj) ;
	
	CLEAN_ZLANGDIRECTPROPERTY_guiwidget_common(guivideo)

	ZLFREE( guivideo_direct_prop );
	
	return;
}

ZlangSummarizeDirectPropertySizeFunction ZlangSummarizeDirectPropertySize_guivideo;
void ZlangSummarizeDirectPropertySize_guivideo( struct ZlangRuntime *rt , struct ZlangObject *obj , size_t *summarized_obj_size , size_t *summarized_direct_prop_size )
{
	SUMMARIZE_SIZE( summarized_direct_prop_size , sizeof(struct ZlangDirectProperty_guivideo) )
	return;
}

static struct ZlangDirectFunctions direct_funcs_guivideo =
	{
		ZLANG_OBJECT_guivideo , /* char *ancestor_name */
		
		ZlangCreateDirectProperty_guivideo , /* ZlangCreateDirectPropertyFunction *create_entity_func */
		ZlangDestroyDirectProperty_guivideo , /* ZlangDestroyDirectPropertyFunction *destroy_entity_func */
		
		NULL , /* ZlangFromCharPtrFunction *from_char_ptr_func */
		NULL , /* ZlangToStringFunction *to_string_func */
		NULL , /* ZlangFromDataPtrFunction *from_data_ptr_func */
		NULL , /* ZlangGetDataPtrFunction *get_data_ptr_func */
		
		NULL , /* ZlangOperatorFunction *oper_PLUS_func */
		NULL , /* ZlangOperatorFunction *oper_MINUS_func */
		NULL , /* ZlangOperatorFunction *oper_MUL_func */
		NULL , /* ZlangOperatorFunction *oper_DIV_func */
		NULL , /* ZlangOperatorFunction *oper_MOD_func */
		
		NULL , /* ZlangUnaryOperatorFunction *unaryoper_NEGATIVE_func */
		NULL , /* ZlangUnaryOperatorFunction *unaryoper_NOT_func */
		NULL , /* ZlangUnaryOperatorFunction *unaryoper_BIT_REVERSE_func */
		NULL , /* ZlangUnaryOperatorFunction *unaryoper_PLUS_PLUS_func */
		NULL , /* ZlangUnaryOperatorFunction *unaryoper_MINUS_MINUS_func */
		
		NULL , /* ZlangCompareFunction *comp_EGUAL_func */
		NULL , /* ZlangCompareFunction *comp_NOTEGUAL_func */
		NULL , /* ZlangCompareFunction *comp_LT_func */
		NULL , /* ZlangCompareFunction *comp_LE_func */
		NULL , /* ZlangCompareFunction *comp_GT_func */
		NULL , /* ZlangCompareFunction *comp_GE_func */
		
		NULL , /* ZlangLogicFunction *logic_AND_func */
		NULL , /* ZlangLogicFunction *logic_OR_func */
		
		NULL , /* ZlangLogicFunction *bit_AND_func */
		NULL , /* ZlangLogicFunction *bit_XOR_func */
		NULL , /* ZlangLogicFunction *bit_OR_func */
		NULL , /* ZlangLogicFunction *bit_MOVELEFT_func */
		NULL , /* ZlangLogicFunction *bit_MOVERIGHT_func */
		
		ZlangSummarizeDirectPropertySize_guivideo , /* ZlangSummarizeDirectPropertySizeFunction *summarize_direct_prop_size_func */
	} ;

ZlangImportObjectFunction ZlangImportObject_guivideo;
struct ZlangObject *ZlangImportObject_guivideo( struct ZlangRuntime *rt )
{
	struct ZlangObject	*obj = NULL ;
	struct ZlangFunction	*func = NULL ;
	int			nret = 0 ;
	
	nret = ImportObject( rt , & obj , ZLANG_OBJECT_guivideo , & direct_funcs_guivideo , sizeof(struct ZlangDirectFunctions) , NULL ) ;
	if( nret )
	{
		SET_RUNTIME_ERROR( rt , RUNTIME_ERROR , ZLANG_ERROR_LINK_FUNC_TO_ENTITY , "import object to global objects heap" )
		return NULL;
	}
	
	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guivideo_Create_guiwindow , ZLANG_OBJECT_guivideo , "Create" , ZLANG_OBJECT_guiwindow,NULL , NULL ) ;
	if( func == NULL )
		return NULL;
	
	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guivideo_Create_guiwindow_string , ZLANG_OBJECT_guivideo , "Create" , ZLANG_OBJECT_guiwindow,NULL , ZLANG_OBJECT_string,NULL , NULL ) ;
	if( func == NULL )
		return NULL;
	
	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guivideo_SetAutoPlay_bool , ZLANG_OBJECT_guivideo , "SetAutoPlay" , ZLANG_OBJECT_bool,NULL , NULL ) ;
	if( func == NULL )
		return NULL;
	
	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guivideo_SetLoopPlay_bool , ZLANG_OBJECT_guivideo , "SetLoopPlay" , ZLANG_OBJECT_bool,NULL , NULL ) ;
	if( func == NULL )
		return NULL;
	
	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guivideo_SetMuted_bool , ZLANG_OBJECT_guivideo , "SetMuted" , ZLANG_OBJECT_bool,NULL , NULL ) ;
	if( func == NULL )
		return NULL;
	
	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guivideo_SetVolume_double , ZLANG_OBJECT_guivideo , "SetVolume" , ZLANG_OBJECT_double,NULL , NULL ) ;
	if( func == NULL )
		return NULL;
	
	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guivideo_LoadVideoFile_string , ZLANG_OBJECT_guivideo , "LoadVideoFile" , ZLANG_OBJECT_string,NULL , NULL ) ;
	if( func == NULL )
		return NULL;
	
	ADD_FUNCTION_AND_PARAMETERS_IN_OBJECT_guiwidget_all_common_functions( video )

	ADD_FUNCTION_AND_PARAMETERS_IN_OBJECT_guictl_all_common_functions( video )

	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guivideo_GetVideoWidth , ZLANG_OBJECT_int , "GetVideoWidth" , NULL ) ;
	if( func == NULL )
		return NULL;
	
	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guivideo_GetVideoHeight , ZLANG_OBJECT_int , "GetVideoHeight" , NULL ) ;
	if( func == NULL )
		return NULL;
	
	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guivideo_GetAutoPlay , ZLANG_OBJECT_bool , "GetAutoPlay" , NULL ) ;
	if( func == NULL )
		return NULL;
	
	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guivideo_GetLoopPlay , ZLANG_OBJECT_bool , "GetLoopPlay" , NULL ) ;
	if( func == NULL )
		return NULL;
	
	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guivideo_GetMuted , ZLANG_OBJECT_bool , "GetMuted" , NULL ) ;
	if( func == NULL )
		return NULL;
	
	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guivideo_GetVolume , ZLANG_OBJECT_double , "GetVolume" , NULL ) ;
	if( func == NULL )
		return NULL;
	
	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guivideo_Play , ZLANG_OBJECT_bool , "Play" , NULL ) ;
	if( func == NULL )
		return NULL;
	
	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guivideo_Stop , ZLANG_OBJECT_bool , "Stop" , NULL ) ;
	if( func == NULL )
		return NULL;
	
	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guivideo_Pause , ZLANG_OBJECT_bool , "Pause" , NULL ) ;
	if( func == NULL )
		return NULL;
	
	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guivideo_IsPrepared , ZLANG_OBJECT_bool , "IsPrepared" , NULL ) ;
	if( func == NULL )
		return NULL;
	
	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guivideo_GetDuration , ZLANG_OBJECT_long , "GetDuration" , NULL ) ;
	if( func == NULL )
		return NULL;
	
	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guivideo_GetTimestamp , ZLANG_OBJECT_long , "GetTimestamp" , NULL ) ;
	if( func == NULL )
		return NULL;
	
	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guivideo_Seek_long , ZLANG_OBJECT_bool , "Seek" , ZLANG_OBJECT_long,NULL , NULL ) ;
	if( func == NULL )
		return NULL;
	
	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guivideo_SeekOffset_long , ZLANG_OBJECT_bool , "SeekOffset" , ZLANG_OBJECT_long,NULL , NULL ) ;
	if( func == NULL )
		return NULL;
	
	return obj ;
}

